var editrow;

$(function(){
	var parentW = frame.window.getOpenParent();
	editrow = parentW.$('#dg').datagrid("getSelected");
	loadData();
});

function loadData() {
	$.post(frame.fullUrl("/base/acount/allsun.json"), editrow,
		function(acounts) {
			$("#dg").edatagrid({
				data : acounts
			});
		}
	)
}

function click_copy() {
	$.ajax(frame.fullUrl("/base/acount/copyacount.json"), {
		data : editrow,
		mask : true,
		type : 'post',
		success : loadData
	});
}

function click_delete(){
	var selectRow = $('#dg').datagrid("getSelected");
	if(selectRow){
		$.messager.confirm('确认', '您确认想要删除账户吗？', function(r) {
			$.ajax(frame.fullUrl("/base/acount/delete.json"), {
				data : selectRow,
				mask : true,
				type : 'post',
				success : loadData
			});
		});
	} else {
		alert("请选择账户");
	}
}

function click_group_synch(){
	$.ajax(frame.fullUrl("/base/acount/synchgroup.json"), {
		data : editrow,
		mask : true,
		type : 'post',
		success : loadData
	});
}
